package cn.itcast.service.impl;

import cn.itcast.annotation.AddAnnotation;
import cn.itcast.annotation.UpdateAnnotation;
import cn.itcast.mapper.DeptMapper;
import cn.itcast.pojo.Dept;
import cn.itcast.service.DeptService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
@Service
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> findAll() {
        return deptMapper.selectList( null);
    }

    @Override
    public boolean deleteById(Integer id) {
        int row = deptMapper.deleteById( id);
        return row > 0;
    }

    @Override
    @AddAnnotation
    public boolean add(Dept dept) {
        int row = deptMapper.insert(dept);
        return row > 0;
    }

    @Override
    public Dept findById(Integer id) {
        Dept dept = deptMapper.selectById( id);
        return dept;
    }

    @Override
    @UpdateAnnotation
    public boolean update(Dept dept) {
        int row = deptMapper.updateById(dept);
        return row > 0;
    }
}
